package com.medisched.medisched.controller;

import com.medisched.medisched.domain.Usertable;
import com.medisched.medisched.service.IUsertableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@CrossOrigin
@RestController
@RequestMapping("/system/usertable")
public class UsertableController 
{
    @Autowired
    private IUsertableService usertableService;

    /**
     * 查询用户列表
     */
    @GetMapping("/list")
    public List<Usertable>  list(Usertable usertable)
    {
        List<Usertable> list = usertableService.selectUsertableList(usertable);
        return (list);
    }

    /**
     * 获取用户详细信息
     */
    @GetMapping(value = "/{id}")
    public Usertable getInfo(@PathVariable("id") Long id)
    {
        return (usertableService.selectUsertableById(id));
    }


    /**
     * 用户-科室-角色 关联查询
     */
    @GetMapping(value = "/getInfoAll/{id}")
    public Usertable getInfoAll(@PathVariable("id") Long id)
    {
        return (usertableService.selectUserAlltableById(id));
    }

    /**
     * 新增用户
     */
    @PostMapping
    public int add(@RequestBody Usertable usertable)
    {
        return (usertableService.insertUsertable(usertable));
    }

    /**
     * 修改用户
     */
    @PutMapping
    public int edit(@RequestBody Usertable usertable)
    {
        return (usertableService.updateUsertable(usertable));
    }

    /**
     * 删除用户
     */
	@DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids)
    {
        return (usertableService.deleteUsertableByIds(ids));
    }
}
